<?php
error_reporting(0);
session_start();

if (!isset($_SESSION["email"])) {
    include "includes/accessDeniedInclude.php";
}

include_once "src/model/Consultant.php";
include_once "src/controller/regmanagement/AccountManager.php";
include_once "src/controller/regmanagement/MiscellaneousManager.php";

try {
    $user = AccountManager::getConsultant($_SESSION["email"]);
    $isAccountPage = true;
} catch (Exception $e) {
    echo $e->getMessage();
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Safety & Security Consultant Registry of Texas</title>
        <style type="text/css">
            @import "js/dojo/dojox/image/resources/image.css";
            @import "js/dojo/dijit/themes/tundra/tundra.css";
            @import "js/dojo/dojox/grid/resources/Grid.css";
            @import "js/dojo/dojox/grid/resources/tundraGrid.css";
        </style>
        <link href="styles/default.css"
              rel="stylesheet"
              type="text/css"
              media="all">
        <script src="js/dojo/dojo/dojo.js"
                type="text/javascript"
                djConfig="parseOnLoad:true">
        </script>
        <script src="js/default.js" type="text/javascript"></script>
        <script type="text/javascript">
            dojo.require("dojo.parser");
            dojo.require("dijit.layout.AccordionContainer");
            dojo.require("dijit.dijit");
            dojo.require("dojox.grid.DataGrid");
            dojo.require("dojo.data.ItemFileWriteStore");
            dojo.require("dijit.form.ValidationTextBox");
            dojo.require("dijit.form.Button");
            dojo.require("dijit.Dialog");
            dojo.require("dijit.form.CheckBox");
            dojo.require("dijit.ProgressBar");
            dojo.require("dijit.form.Form");
            dojo.require("dijit.form.Textarea");
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojo.data.ItemFileWriteStore");

            dojo.addOnLoad(function () {

                dojo.connect(dijit.byId('passwordRecoveryDialog'), 'hide', function(){
                    document.body.style.overflow = "";
                    clearPasswordRecoveryForm();
                });

                refreshUserInformationLeftArea();

            });
        </script>
    </head>
    <body class="tundra">

        <div dojoType="dijit.Dialog"
             id="passwordRecoveryDialog"
             title="Safety & Security Consultant Registry of Texas"
             style="display:none;">
            <table border="0" cellpadding="0" cellspacing="0" width="500" height="250">
                <tbody>
                    <tr>
                        <td style="width:30px;background-image:url('images/dialogBg.png');background-repeat:repeat-y;"></td>
                        <td align="center"
                            valign="top"
                            id="passwordRecoveryDialogArea"
                            style="padding-top:10px;padding-right:10px;">
                            <?php include "includes/passwordRecoveryFormInclude.php"; ?>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <table class="main">
            <thead>
                <tr class="mainHeader">
                    <th align="center">
                        <?php include "includes/topMenuInclude.php"; ?>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="center" valign="top">
                        <table class="mainBody">
                            <tbody>
                                <tr style="height:15px;">
                                    <td style="width:175px;"></td>
                                    <td style="width:795px;"></td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        <?php include "includes/leftBarInclude.php"; ?>
                                    </td>
                                    <td valign="top" style="padding-left:20px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                            <tbody>
                                                <tr>
                                                    <td class="pageMainTitle">
                                                        User Account
                                                        <br />
                                                        <span style="font-size:10px;">
                                                            This information is only for setting up your account and will not
                                                            be made available to the public at any time. You can duplicate this
                                                            information on your profile if you wish to use the same name and email
                                                            as your public contact information.
                                                        </span>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="height:10px;"></td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div id="userAccountFormStatus"
                                                             class="userProfileFormStandardMessage">
                                                            <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
                                                                <tbody>
                                                                    <tr>
                                                                        <td id="userAccountFormStatusMessage" style="width:100%;text-align:left;font-family:Verdana;font-size:12px;font-weight:bold;padding-left:5px;padding-top:7px;"></td>
                                                                        <td style="text-align:right;"></td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="padding-left:10px;padding-right:10px;padding-top:10px;padding-bottom:10px;border:1px solid #AAAAAA;background-color:#EEEEEE;">
                                                        <form  dojoType="dijit.form.Form"
                                                               name="userAccountForm"
                                                               id="userAccountForm"
                                                               method="post"
                                                               action="">
                                                            <input type="hidden"
                                                                   id="consultantId"
                                                                   name="consultantId"
                                                                   value="<?php echo $user->getConsultantId();?>" />
                                                            <input type="hidden"
                                                                   id="accountCreationDate"
                                                                   name="accountCreationDate"
                                                                   value="<?php echo $user->getAccountCreationDate();?>" />
                                                            <input type="hidden"
                                                                   id="oldFirstName"
                                                                   name="oldFirstName"
                                                                   value="<?php echo $user->getFirstName();?>" />
                                                            <input type="hidden"
                                                                   id="oldLastName"
                                                                   name="oldLastName"
                                                                   value="<?php echo $user->getLastName();?>" />
                                                            <table border="0" class="userProfileTable" width="100%">
                                                                <tbody>
                                                                    <tr>
                                                                        <td style="vertical-align:top;"><span class="requiredSign">*</span></td>
                                                                        <td colspan="2" style="vertical-align:top;width:145px;padding-bottom:10px;">
                                                                            <table border="0" cellpadding="0" cellspacing="0" style="font-family:Verdana;font-size:12px;font-weight:normal;">
                                                                                <tbody>
                                                                                    <tr>
                                                                                        <td style="padding-bottom:2px;padding-top:0px;">First Name:</td>
                                                                                        <td rowspan="2" style="padding-left:10px;padding-right:3px;vertical-align:top;text-align:right;"><span class="requiredSign">*</span></td>
                                                                                        <td style="padding-bottom:2px;padding-top:0px;">Last Name:</td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td style="padding-bottom:0px;padding-top:0px;">
                                                                                            <input style="width:140px;"
                                                                                                   type="text"
                                                                                                   name="firstName"
                                                                                                   id="firstName"
                                                                                                   value="<?php echo $user->getFirstName();?>"
                                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                                   trim="true"
                                                                                                   regExp="[\a-zA-Z\.\-\,\' ]+"
                                                                                                   propercase="true"
                                                                                                   required="true" />
                                                                                        </td>
                                                                                        <td style="padding-bottom:0px;padding-top:0px;">
                                                                                            <input style="width:142px;"
                                                                                                   type="text"
                                                                                                   name="lastName"
                                                                                                   id="lastName"
                                                                                                   value="<?php echo $user->getLastName();?>"
                                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                                   trim="true"
                                                                                                   regExp="[\a-zA-Z\.\-\,\' ]+"
                                                                                                   propercase="true"
                                                                                                   required="true" />
                                                                                        </td>
                                                                                    </tr>
                                                                                </tbody>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td rowspan="2" style="vertical-align:top;"><span class="requiredSign">*</span></td>
                                                                        <td colspan="2"  style="vertical-align:top;">Email Address:</td>
                                                                        <td></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align:top;padding-bottom:20px;">
                                                                            <input style="width:310px;"
                                                                                   type="text"
                                                                                   name="email"
                                                                                   id="email"
                                                                                   value="<?php echo $user->getEmail();?>"
                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                   maxLength="50"
                                                                                   lowercase="true"
                                                                                   regExp="[\a-zA-Z0-9\-\.\_\#]+[\@][a-zA-Z0-9\-\.\_\#]+[\.][a-zA-Z0-9\-\.\_\#]+"
                                                                                   required="true" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td></td>
                                                                        <td colspan="2" style="vertical-align:top;padding-bottom:10px;">
                                                                            <input id="changePasswordIndicator"
                                                                                   dojotype="dijit.form.CheckBox"
                                                                                   name="changePasswordIndicator"
                                                                                   value="1"
                                                                                   type="checkbox"
                                                                                   onclick="activateChangeUserAccountPassword();" />
                                                                            <label for="changePasswordIndicator" style="font-family:Verdana;font-size:12px;font-weight:bold;">I want to change my password</label>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td rowspan="2" id="oldPasswordRequiredMessage" style="vertical-align:top;"></td>
                                                                        <td colspan="2" style="vertical-align:top;">Old Password:</td>
                                                                        <td></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align:top;padding-bottom:10px;">
                                                                            <input style="width:200px;"
                                                                                   type="password"
                                                                                   name="oldPassword"
                                                                                   id="oldPassword"
                                                                                   value=""
                                                                                   disabled="true"
                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                   trim="true"
                                                                                   regExp="[\a-zA-Z0-9\_]+"
                                                                                   required="true" />
                                                                            <a href="javascript:showPasswordRecoveryForm();" style="font-family:Verdana;font-size:12px;">
                                                                                Forgot your password?
                                                                            </a>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td rowspan="2" id="newPasswordRequiredMessage" style="vertical-align:top;"></td>
                                                                        <td colspan="2" style="vertical-align:top;">New Password:</td>
                                                                        <td></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align:top;padding-bottom:10px;">
                                                                            <input style="width:200px;"
                                                                                   type="password"
                                                                                   name="newPassword"
                                                                                   id="newPassword"
                                                                                   value=""
                                                                                   disabled="true"
                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                   trim="true"
                                                                                   regExp="[\a-zA-Z0-9\_]+"
                                                                                   required="true" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td rowspan="2" id="confirmationPasswordRequiredMessage" style="vertical-align:top;"></td>
                                                                        <td colspan="2" style="vertical-align:top;">Confirm New Password:</td>
                                                                        <td></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align:top;padding-bottom:10px;">
                                                                            <input style="width:200px;"
                                                                                   type="password"
                                                                                   name="confirmationNewPassword"
                                                                                   id="confirmationNewPassword"
                                                                                   value=""
                                                                                   disabled="true"
                                                                                   dojoType="dijit.form.ValidationTextBox"
                                                                                   trim="true"
                                                                                   regExp="[\a-zA-Z0-9\_]+"
                                                                                   required="true" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="3" style="text-align:right;padding-top:10px;padding-bottom:0px;border-top:1px solid #AAAAAA;">
                                                                            <button dojoType=dijit.form.Button
                                                                                    type="reset"
                                                                                    name="resetUserAccountForm"
                                                                                    id="resetUserAccountForm"
                                                                                    iconClass="clearIcon"
                                                                                    onclick="">
                                                                                Clear Account Form
                                                                            </button>
                                                                            <button type="button"
                                                                                    name="deleteUserAccount"
                                                                                    id="deleteUserAccount"
                                                                                    dojoType="dijit.form.Button"
                                                                                    iconClass="deleteIcon"
                                                                                    onclick="deleteUserAccount()">
                                                                                Delete Account
                                                                            </button>
                                                                            <button dojoType=dijit.form.Button
                                                                                    type="button"
                                                                                    name="submitUserAccountForm"
                                                                                    id="submitUserAccountForm"
                                                                                    iconClass="saveIcon"
                                                                                    onclick="submitUserAccountForm()">
                                                                                Save Account
                                                                            </button>
                                                                        </td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </form>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="top">
                        <?php include "includes/mainFooterInclude.php"; ?>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
